{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1b2ecb63",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "设备已启动.....\n"
     ]
    }
   ],
   "source": [
    "import ZWDX_DDS_UART\n",
    "obj = ZWDX_DDS_UART.ZWDDS1000Connect(\"COM7\")\n",
    "obj.start()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "39d90769",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "设备自检结果:\n",
      "      1.设备已启动\n",
      "      2.通道开关状态:0x0\n",
      "      3.通道1衰减值为:0.0dBm\n",
      "      4.通道2衰减值为:0.0dBm\n",
      "      5.通道3衰减值为:0.0dBm\n",
      "      6.通道4衰减值为:0.0dBm\n",
      "      7.通道5衰减值为:0.0dBm\n",
      "      8.通道6衰减值为:0.0dBm\n",
      "      9.通道7衰减值为:0.0dBm\n",
      "      10.通道8衰减值为:0.0dBm\n",
      "      12.profilepin由外部控制\n",
      "      13.通道1:prifilepin值为:0x0\n",
      "      14.通道2:prifilepin值为:0x0\n",
      "      15.通道3:prifilepin值为:0x0\n",
      "      16.通道4:prifilepin值为:0x0\n",
      "      17.通道5:prifilepin值为:0x0\n",
      "      18.通道6:prifilepin值为:0x0\n",
      "      19.通道7:prifilepin值为:0x0\n",
      "      20.通道8:prifilepin值为:0x0\n",
      "      22.设备ip：192.168.1.140, port: 8080\n",
      "      23.设备id: DDS1000_NUM1_202208\n",
      "      24.设备温度:53.017°C\n"
     ]
    }
   ],
   "source": [
    "obj.SelfCheck()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a781658b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2022-10-10 17:21:38 :发送启动命令\n",
      "2022-10-10 17:21:41 :机箱启动成功\n"
     ]
    }
   ],
   "source": [
    "obj.ClkSyncConfig(0,0)         #初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "76659bc5",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.AD9910RegWrite(1, 0x0E, '0x3fff000051eb851e')      #寄存器写入和ioupdate使用\n",
    "obj.AD9910IoUpdate(0xff)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "d8cc7b6b",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.AD9910RegWrite(1, 0x0f, '0x3fff0000178d4fdf')      #寄存器写入和ioupdate使用\n",
    "obj.AD9910IoUpdate(0xff)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "b57e93c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.AD9910RegWrite(1, 0x0E, '0x3fff000000418937')      #寄存器写入和ioupdate使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "83556b76",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.AD9910IoUpdate(0xff)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3286a2c1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "通道号:1,地址:14,AD9910寄存器内容:0x3fff0000051eb850\n"
     ]
    }
   ],
   "source": [
    "obj.AD9910RegRead(1, 0x0E)       #寄存器读取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0aa599d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetProfilePinMode(0x0)             #profilepin模式  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "552765ea",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetRFOnOff(0xFF)                   #通道开启关闭"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "16d687e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetProfilePinDefault()            #profilepin恢复成默认值 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "2804ef80",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n",
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n",
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n",
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n",
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n",
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n",
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n",
      "Profilepin模式不是上位机控制,请重新设置Profilepin模式....\n"
     ]
    }
   ],
   "source": [
    "for i in range(1,9,1):\n",
    "    obj.SetProfilePin(i, 0)            #设置profilepin值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "11d00ec2",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(1, 1000 ,1):\n",
    "    obj.SetProfilePinSoftTrig()        #设置profilepin触发\n",
    "    time.sleep(0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "6f9652ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetProfilePinSoftTrig()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a138c861",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetProfilePinMode(0x3) \n",
    "obj.SetProfilePin(1, 4)            #设置profilepin值\n",
    "time.sleep(0.1)\n",
    "obj.SetProfilePinSoftTrig()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "94d68594",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetProfilePin(1,1)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "0892369c",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.AD9910RegWrite(5, 0x15, '0x3fff800003333333')      #寄存器写入和ioupdate使用\n",
    "obj.AD9910IoUpdate(0xff)\n",
    "obj.SetProfilePin(5, 7)  \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "bc25c26f",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.AD9910IoUpdate(0xff)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e2310119",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(1, 9, 1):\n",
    "    obj.SetRFPower(i, 0)   #设置衰减"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "405a2fc2",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetRFPower(8, 10)   #设置衰减"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "d29871c9",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.SetTrigDelay(0x2)\n",
    "obj.SetProfilePin(1,0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "bc690ceb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4,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, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]\n",
      "2\n",
      "40\n",
      "包数：3, 总字节数：4500\n"
     ]
    }
   ],
   "source": [
    "dlenth = 1024\n",
    "mdata = []\n",
    "val = [0,0,0,0,0,0,0,0]\n",
    "#         val = [0,1,2,3,4,5,6,7]\n",
    "for i in range(0, dlenth, 1):\n",
    "    mdata.append(val[i%8])\n",
    "    val[i%8] = val[i%8]+1;\n",
    "    if val[i%8] >7:\n",
    "        val[i % 8] = 0\n",
    "print(mdata)\n",
    "obj.SetProfilePinDRAMData(mdata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5369b6d",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.ZWDDS1000DisConnect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a3a0ce75",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj.FanCtrl(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aceba7f9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
